<template>
  <div class="container">
    <div class="wrapper">
      <div class="return">
        <i class="ri-arrow-left-s-line" @click="toPersonal"></i>
      </div>
      <div class="left-top-sign">LOGIN</div>
      <div class="welcome">欢迎回来！</div>
      <div class="input-content">
        <div class="input-item">
          <span class="tit">用户名</span>
          <input type="text" placeholder="用户名" id="phone" v-model="phone" />
        </div>
        <div class="input-item">
          <span class="tit">密码</span>

          <input
            type="password"
            placeholder="请输入密码"
            id="password"
            v-model="password"
          />
        </div>
      </div>
      <button class="confirm-btn" @click="logon">登录</button>
      <div class="forget-section">忘记密码?</div>
    </div>
    <div class="register-section">
      还没有账号?
      <span>马上注册</span>
    </div>
  </div>
</template>

<script>
  
  export default {
    name: "Logon",
    data() {
      return {
        phone: "", //用户手机号
        password: "", //密码
      };
    },
    methods: {
      // 点击登录按钮
      async logon() {
        //  判断有没有用户名
        if (this.phone === "") {
          this.$message.warning("请输入正确用户名");
          return;
        }
        //  判断有没有密码
        if (this.password === "") {
          this.$message.warning("请输入密码");
          return;
        }

        //  触发vuex里的方法，如果返回失败则不往下走  await
        await this.$store.dispatch("logon/getGoLogin", {
          username: this.phone,
          pwd: this.password,
        });
        // 如果成功 则跳转路由
        this.$router.push({
          name: "personal",
        });
      },

      //点击返回箭头  跳转到个人中心
      toPersonal() {
        this.$router.push({
          name: "personal",
        });
      },
    },
  };
</script>

<style lang="less" scoped>
  /* 返回键 */
  .return {
    // width: 100%;
    height: 80px;
    /* background-color: #bfa; */
    line-height: 80px;
    font-size: 80px;
    margin-top: 50px;
  }

  /* 上部整体容器 */
  .wrapper {
    position: relative;
    z-index: 90;
    padding-bottom: 40px;
  }

  .left-top-sign {
    font-size: 120px;
    color: #ffffff;
    position: relative;
    left: -16px;
  }
  /* 欢迎回来字体 */
  .welcome {
    position: relative;
    left: 50px;
    top: -90px;
    font-size: 46px;
    color: #555;
  }

  /* 两个输入框容器 */
  .input-content {
    padding: 0 60px;
    margin-top: 150px;
  }
  /* 输入框容器 */
  .input-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0 30px;
    /* background: #673fb6; */
    height: 140px;
    border-radius: 4px;
    margin-bottom: 50px;
  }

  .input-item:last-child {
    margin-bottom: 0;
  }
  /* 字体 */
  .input-item .tit {
    height: 50px;
    line-height: 56px;
    font-size: 30px;
    color: #606266;
  }
  /* 输入框 */
  .input-item input {
    height: 80px;
    font-size: 30px;
    color: #303133;
    width: 100%;
  }
  /* 登录按钮 */
  .confirm-btn {
    width: 630px;
    height: 76px;
    line-height: 76px;
    border-radius: 50px;
    margin-top: 70px;
    margin-left: 170px;
    background: #845f3f;
    color: #fff;
    font-size: 32px;
    padding: 0;
  }

  .confirm-btn2:after {
    border-radius: 100px;
  }
  /* 忘记密码 */
  .forget-section {
    font-size: 28px;
    color: #4399fc;
    text-align: center;
    margin-top: 40px;
  }
  /* 没有账号 */
  .register-section {
    position: absolute;
    left: 0;
    bottom: 50px;
    width: 100%;
    font-size: 28px;
    color: #606266;
    text-align: center;
  }
  /* 字体 */
  .register-section span {
    color: #4399fc;
    margin-left: 10px;
  }
</style>